<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="apple-wap-web-app-capable" content="yes">
    <meta name="apple-wap-web-app-status-bar-style" content="black-translucent">
    <meta name="MobileOptimized" content="240"/>
    <title>积分排名</title>
    <link rel="stylesheet" href="$!webPath/css/reset.css" />
    <link rel="stylesheet" href="$!webPath/css/style.css" />
    <link rel="stylesheet" href="$!webPath/css/style_my.css" />
    <script src="$!webPath/js/jquery.min.js"></script>
</head>
<body style="background-color: #2F2D32">
<div class="all">
    <div class="rankingTitle">
        积分排位赛总排名
    </div>
    <div class="rankingTable">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <th width="15%" align="center">排名</th>
                <th width="20%" align="center">战队</th>
                <th width="15%" align="center">所在地</th>
                <th width="15%" align="center">胜场</th>
                <th width="15%" align="center">败场</th>
                <th width="20%" align="center">积分</th>
            </tr>
            #set($n = 0)
            #foreach($obj in $!teamRanking)
            #set($n = $n+1)
            <tr>
                #if($n == 1)
                <td>
                    <img src="$!webPath/imgs/crown.png" width="20px">
                </td>
                #else
                <td>
                    $n
                </td>
                #end
                <td>
                    <a href="$!webPath/team/teamDetails?teamId=$!{$!teamRanking.id}">$!obj.name</a>
                </td>
                <td>
                    $!obj.location
                </td>
                <td>
                    $!obj.winNum
                </td>
                <td>
                    $!obj.loseNum
                </td>
                <td>
                    $!obj.teamIntegral
                </td>
            </tr>
            #end
        </table>
        <!--<div style="font-size: 14px;color: #7c7d7d;">
        <span id="spanFirst">第一页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span>
        </div>-->
    </div>
    <a href="$!webPath/team/getMyTeam" class="myteamBtn">
        我的战队
    </a>
</div>
<div class="footer">
    <a href="$!webPath/home/index"><img width="100%" src="$!webPath/imgs/a1.png"></a>
    <a href="$!webPath/activity/activity_list"><img width="100%" src="$!webPath/imgs/b1.png"></a>
    <a href="$!webPath/team/ranking?page=0&size=20" style="background-color: #ffcc00"><img width="100%" src="$!webPath/imgs/c2.png"></a>
    <a href="$!webPath/ticket/list"><img width="100%" src="$!webPath/imgs/d1.png"></a>
    <a href="$!webPath/user/my_account"><img width="100%" src="$!webPath/imgs/e1.png"></a>
</div>
<script>
    var mar_height=$('.footer a img').css('height');
    $('.all').css('margin-bottom',mar_height);
    getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }
    var pageSize = getUrlParam('size');
    var page = parseInt(getUrlParam('page'));

    //替换指定传入参数的值,paramName为参数,replaceWith为新值
    function replaceParamVal(paramName,replaceWith) {
        var oUrl = this.location.href.toString();
        var re=eval('/('+ paramName+'=)([^&]*)/gi');
        var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
        this.location = nUrl;
    }

    $('#spanFirst').click(function () {
        page=0
        $.ajax({
            url:'$!webPath/admin/teamList?size=10&page='+page,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/team/ranking?size=20&page='+page;
                replaceParamVal('page',page);
            }
        })
    })
    $('#spanNext').click(function(){
        page++;

        $.ajax({
            url:'$!webPath/admin/teamList?size=10&page='+page,
            success:function(data){

                console.log(page);
                console.log(data);
                window.location.href='$!webPath/team/ranking?size=20&page='+page;
                replaceParamVal('page',page);

            }
        })
    })

    $('#spanPre').click(function(){
        //location.reload()
        page--;
        if(page<=0){
            page=0;
        }
        $.ajax({
            url:'$!webPath/admin/teamList?size=10&page='+page,
            success:function(data){
                console.log(data);
                window.location.href='$!webPath/team/ranking?size=20&page='+page;
                replaceParamVal('page',page);

            }
        })
    })
</script>
</body>
</html>